﻿<div class="page-bar">
    <ul class="page-breadcrumb">
        <li>
            <span id="module">佛吉亚管理</span>
            <i class="fa fa-angle-right"></i>
        </li>
        <li>
            <span id="action"></span>
        </li>
    </ul>
</div>
<!-- END PAGE BAR -->
<div class="mt-bootstrap-tables" style="margin-top:20px">
    <div class="row">
        <div class="col-md-12">
            <div class="portlet light bordered">
                <div class="portlet-title">
                    <div class="caption">
                        <i class="icon-social-dribbble font-green hide"></i>
                    </div>
                    <div class="actions">
                        <a class="btn btn-default" href="@Url.Action("Edit")">
                            <i class="fa fa-plus"></i>创建
                        </a>
                    </div>
                </div>

                <div class="portlet-body">
                    <!-- BEGIN FORM-->
                    <form id="defaultForm" class="form-horizontal" method="post" novalidate="novalidate">
                        <div class="mt-checkbox-inline" style="margin-top: -37px">
                            <div class="pull-left" style="margin-top: 20px">
                                状态：
                                <select class="form-control input-inline" name="Enabled" id="State">
                                    <option value="">全部</option>
                                    <option value="true">正常</option>
                                    <option value="false">禁用</option>
                                </select>
                            </div>
                        </div>
                    </form>
                    <!-- END FORM-->
                    <table id="table-pagination" data-toggle="table" data-url="@Url.Action("GetPagedList")"
                           data-height="526"
                           data-form-id="defaultForm"
                           data-show-refresh="true"
                           data-page-size="10"
                           data-page-list="[5, 10, 20, 50, 100, 200]"
                           data-search="true">
                        <thead>
                            <tr>
                                <th data-formatter="RowNumber" data-width="50">序号</th>
                                <th data-field="RealName" data-formatter="opRnameColumns">姓名</th>
                                <th data-field="Account">登录名</th>
                                <th data-align="center" data-field="EnabledMark" data-formatter="opStateColumns" data-width="200">状态</th>
                                <th data-align="center" data-formatter="opColumns" data-width="220">操作</th>
                            </tr>
                        </thead>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>
@section scripts{
    <script type="text/javascript">
        var opColumns = function (value, row, index) {
                if (row.IsSuperAdmin) {
                    return "-";
                }
                else if (row.EnabledMark == null || row.EnabledMark) {
                    return ("<a href=\"@Url.Action("Edit")?memberid=_id_\">编辑</a> | <a href=\"@Url.Action("Assignment")?memberid=_id_\">角色</a> | <a href=\"javascript:_updateState('_id_'," + false + ");\">" + "禁用" + "</a>").replace(/_id_/ig, row.Id).replace(/_name_/ig, encodeURI(row.Account));

                } else if (!row.EnabledMark) {
                    return ("<a href=\"@Url.Action("Edit")?memberid=_id_\">编辑</a> | <a href=\"@Url.Action("Assignment")?memberid=_id_\">角色</a> | <a href=\"javascript:_updateState('_id_'," + true + ");\">" + "启用" + "</a> | <a href=\"javascript:_delete('_id_');\">删除</a>").replace(/_id_/ig, row.Id).replace(/_name_/ig, encodeURI(row.Account));
                }
            },
     
            _delete = function(id) {
                bootbox.confirm("是否确认删除？", function (result) {
                    if (!result) {
                        return;
                    }
                    $.ajax({
                        type: "POST",
                        url: "@Url.Action("DeleteMember")",
                        data: { memberId: id },
                        async: false,
                        success: function (result) {
                            if (result.Success) {
                                $("#table-pagination").bootstrapTable('refresh');
                            } else {
                                showToast(3, '系统消息', result.Message);
                            }
                        }
                    });
                });

            };
    </script>
}
